package com.imooc.es.pojo;


import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

// es7 type可以不用填写 @Document注解中的属性中为索引的一些信息
// createIndex : 在没有索引的情况下是否会自动创建索引
@Document(indexName = "foodie-items-ik",type="_doc",createIndex = false)
public class Items {
    /**
     * 使用 @Id注解，当 itemId为1001时，它会自动为我们创建一个
     * 值为1001的文档Id
     * 若没有使用@ID注解，那么文档Id就是自动生成的
     * index = false : 不需要对该字段的值做倒排索引
     */
    @Id
    @Field(store=true,type = FieldType.Text,index = false)
    private String itemId;

    @Field(store=true,type = FieldType.Text,index = true)
    private String itemName;

    @Field(store=true,type = FieldType.Text,index = false)
    private String imgUrl;

    @Field(store=true,type = FieldType.Integer)
    private Integer price;

    @Field(store=true,type = FieldType.Integer)
    private Integer sellCounts;

    public String getItemId() {
        return itemId;
    }

    public void setItemId(String itemId) {
        this.itemId = itemId;
    }

    public String getItemName() {
        return itemName;
    }

    public void setItemName(String itemName) {
        this.itemName = itemName;
    }

    public String getImgUrl() {
        return imgUrl;
    }

    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }

    public Integer getPrice() {
        return price;
    }

    public void setPrice(Integer price) {
        this.price = price;
    }

    public Integer getSellCounts() {
        return sellCounts;
    }

    public void setSellCounts(Integer sellCounts) {
        this.sellCounts = sellCounts;
    }

    @Override
    public String toString() {
        return "Items{" +
                "itemId='" + itemId + '\'' +
                ", itemName='" + itemName + '\'' +
                ", imgUrl='" + imgUrl + '\'' +
                ", price=" + price +
                ", sellCounts=" + sellCounts +
                '}';
    }
}
